fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

date_time

time.date_time

date_time(year i64,month i64,day i64,hour i64,minute i64,second i64,nano_second_ i64):orderable is[src]
Precondition
pre
  debug: 1 ≤ month ≤ 12
  debug: is_valid_date year month day
  debug: 0 ≤ hour ≤ 23
  debug: 0 ≤ minute ≤ 59
  debug: 0 ≤ second ≤ 60 # possible leap seconds
  debug: 0 ≤ nano_second_ ≤ 1E9

Fields

year i64[src]
month i64[src]
day i64[src]
hour i64[src]
minute i64[src]
second i64[src]

Functions

as_string => String[Redefinition of  Any.as_string][src]
ISO 8601 string for this datetime
example: 2018-09-14T23:59:59.079

redefines:

as_string(u time.units.val) => String[src]
ISO 8601 string for this datetime
example: 2018-09-14T23:59:59.079
day_of_week => i64[src]
0 = Sunday, 1 = Monday, etc.

source: https://c-faq.com/misc/zeller.html
original code by: Tomohiko Sakamoto
dynamic_apply(R:Any,F:Typed_Function R,f F) => R[Inherited from  Any][src]
dynamic_apply -- apply `f.call` to `Any.this`'s dynamic type and value

This can be used to perform operation on values depending on their dynamic
type.

Here is an example that takes a `Sequence Any` that may contain boxed values
of types `i32` and `f64`. We can now write a feature `get_f64` that extracts
these values converted to `f64` and build a function `sum` that sums them up
as follows:


dynamic_type => Type[Inherited from  Any][src]
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.

There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
infix +(other time.duration) => time.this.date_time[src]
add a duration to this date time
infix -(other time.duration) => time.this.date_time[src]
subtract a duration from this date time
milli_second => i64[src]
the millisecond of this datetime
nano_second => i64[src]
the nanosecond of this datetime
prefix $ => String[Inherited from  Any][src]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
unix_time_stamp => u64[src]
convert to unix time stamp
seconds elapsed since 1970-01-01T00:00:00Z
unix_time_stamp_i64 => i64[src]
convert to unix time stamp (i64 version for dates before 1970)

Type Features

type.as_string => String[Inherited from  Type][src]
string representation of this type to be used for debugging.

result has the form "<name>", but this might change in the future

redefines:

type.dynamic_type => Type[Inherited from  Type][src]
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.

Note: Typechecking is undecidable when 'type' is a type, Mark B. Reinhold, 1989
see: https://dspace.mit.edu/bitstream/handle/1721.1/149366/MIT-LCS-TR-458.pdf?sequence=6

redefines:

type.equality(a time.date_time.this,b time.date_time.this) => bool[Redefinition of  property.orderable.type.equality][src]
defines an equality relation for date time
type.from_seconds(n u64) => time.date_time[src]
create a date_time from given seconds since 1970-01-01T00:00:00

NOTE: this does not adjust for leap seconds
type.from_seconds_i64(n i64) => time.date_time[src]
create a date_time from given seconds since 1970-01-01T00:00:00 (i64 version for negative values, i.e. dates before 1970)
type.infix :(T:Any) => bool[Inherited from  Type][src]
Is this type assignable to a type parameter with constraint `T`?

The result of this is a compile-time constant that can be used to specialize
code for a particular type.


it is most useful in conjunction with preconditions or `if` statements as in


or

type.lteq(a time.date_time.this,b time.date_time.this) => bool[Redefinition of  property.partially_orderable.type.lteq][src]
defines a partial order for date time
type.name => String[Inherited from  Type][src]
name of this type, including type parameters, e.g. 'option (list i32)'.
type.prefix $ => String[Inherited from  Type][src]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.

NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913

redefines:

type.type_value => Type[Inherited from  Any][src]
Get a type as a value.

This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.

`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.

Applicable universe features

These are features in universe, that have an argument with a type constraint that matches this features type and can therefore be used with it.
equals(T:property.equatable,a T,b T) => bool[src]
equals -- feature that compares two values using the equality relation
defined in their type
infix !=(T:property.equatable,a T,b T) => bool[src]
infix = -- infix operation as shorthand for 'equals'
infix <(T:property.orderable,a T,b T) => bool[src]
does this come strictly before other?
infix <=(T:property.partially_orderable,a T,b T) => bool[src]
infix <= -- infix operation as shorthand for 'lteq'
infix <>(T:property.orderable,a T,b T) => order[src]
three-way comparison between this and other.

result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
infix =(T:property.equatable,a T,b T) => bool[src]
infix = -- infix operation as shorthand for 'equals'
infix >(T:property.orderable,a T,b T) => bool[src]
does this come strictly after other?
infix >=(T:property.orderable,a T,b T) => bool[src]
does this come after other?
infix ∈(T:property.equatable,a T,s container.Set T) => bool[src]
is `a` contained in `Set` `s`?

This should usually be called using type inference as in

infix ∉(T:property.equatable,a T,s container.Set T) => bool[src]
is `a` not contained in `Set` `s`?

This should usually be called using type inference as in

infix ≤(T:property.partially_orderable,a T,b T) => bool[src]
infix ≤ -- infix operation as shorthand for 'lteq'
infix ≥(T:property.orderable,a T,b T) => bool[src]
does this come after other?
infix ⋄(T:property.orderable,a T,b T) => order[src]
three-way comparison between this and other.

result is < 0 if this < other
result is > 0 if this > other
result is = 0 if this = other
lteq(T:property.partially_orderable,a T,b T) => bool[src]
lteq -- feature that compares two values using the lteq relation
defined in their type
max(T:property.orderable,a T,b T) => T[src]
maximum of two values
memoize(MM:container.Mutable_Map T R,T:property.equatable,R:Any,f Unary R T) => Unary R T[src]
memoize `f`.
wraps f so that f will only be called once for every unique input.

The term "memoization" was coined by Donald Michie in 1968 and
is derived from the Latin word "memorandum" ("to be remembered"),
usually truncated as "memo" in American English, and thus carries
the meaning of "turning a function into something to be remembered".
https://en.wikipedia.org/wiki/Memoization

example:

min(T:property.orderable,a T,b T) => T[src]
minimum of two values
0.099dev (GIT hash e2d5298d8107bb5fe79600fdb06a49bc75756344)
last changed: 2026-11-23